#include<string>
class Solution {
public:

    void reverse(int l,int r,string& s)//别忘了串引用
    {

        while(l<r)
        {
            swap(s[l++],s[r--]);
        }
    }
    string reverseWords(string s) {
        int pos=0;
        while(s.find(" ",pos)<=5e4+10)
        {   
            int pos1=s.find(" ",pos);
            reverse(pos,pos1-1,s);
            pos=pos1+1;
        }
        reverse(pos,s.size()-1,s);
        return s;
    }
};